package com.blog.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.blog.pojo.Blogger;
import com.blog.service.BloggerService;

/**
 * 博主控制层 --登录后台,获取个人信息
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/blogger")
public class BloggerController {

	@Resource
	private BloggerService bloggerService;
	
	/**
	 * 博主登录后台管理
	 * @return
	 */
	@RequestMapping("/loginAdmin")
	public String loginAdmin(Blogger blogger,HttpServletRequest request){
		return "redirect:/admin/main.jsp";
	}
	
	/**
	 * 关于博主个人信息
	 * @return
	 */
	@RequestMapping("/aboutMe")
	public ModelAndView aboutMe(){
		ModelAndView mav = new ModelAndView();
		//获取博主信息
		Blogger blogger = bloggerService.find();
		mav.addObject("blogger", blogger);
		//前台引入页面地址
		mav.addObject("mainPage", "foreground/blogger/info.jsp");
		//页面标题
		mav.addObject("pageTitle", "关于博主-"+blogger.getUserName()+"博客系统");
		System.out.println(mav);
		//数据前往页面
		mav.setViewName("mainTemp");
		return mav;
	}
}
